{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true,
    "pycharm": {
     "is_executing": false
    }
   },
   "outputs": [],
   "source": [
    "import time\n",
    "from tools import montecarlo_python"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "outputs": [],
   "source": [
    "my_cards = [['3H', '3S']]\n",
    "cards_on_table = ['8S', '4S', 'QH', '8C', '4H']\n",
    "expected_results = 40.2\n",
    "players = 2\n",
    "start_time = time.time() + 1e9\n",
    "runs = 10000"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "outputs": [
    {
     "name": "stdout",
     "text": [
      "4.4 s ± 987 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
     ],
     "output_type": "stream"
    }
   ],
   "source": [
    "python_simulator = montecarlo_python.MonteCarlo()\n",
    "\n",
    "%timeit python_simulator.run_montecarlo(my_cards, cards_on_table, players, 1, maxRuns=runs, timeout=start_time, ghost_cards='', opponent_range=1)\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "outputs": [],
   "source": [
    "import cppimport\n",
    "cpp_calc = cppimport.imp(\"tools.montecarlo_cpp.pymontecarlo\")"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "outputs": [
    {
     "name": "stdout",
     "text": [
      "2.32 s ± 1.09 s per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
     ],
     "output_type": "stream"
    }
   ],
   "source": [
    "%timeit cpp_calc.montecarlo(set(my_cards[0]), set(cards_on_table), players, runs)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "outputs": [],
   "source": [
    "# Cython version\n",
    "%load_ext Cython"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "outputs": [],
   "source": [
    "from tools import montecarlo_cython\n",
    "\n",
    "cython_simulator = montecarlo_cython.MonteCarlo()"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%cython\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "outputs": [
    {
     "name": "stdout",
     "text": [
      "3.34 s ± 1.16 s per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
     ],
     "output_type": "stream"
    }
   ],
   "source": [
    "%timeit cython_simulator.run_montecarlo(my_cards, cards_on_table, players, 1, maxRuns=runs, timeout=start_time, ghost_cards='', opponent_range=1)\n",
    "\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "name": "python3",
   "language": "python",
   "display_name": "Python 3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "source": [],
    "metadata": {
     "collapsed": false
    }
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}